package com.jysz.certificate.persistence.model.pm;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.jysz.certificate.persistence.enums.PerformanceAssignStatus;
import com.jysz.certificate.persistence.model.system.Organization;
import com.jysz.certificate.persistence.model.system.Shop;
import com.jysz.certificate.persistence.model.system.User;
import com.jysz.webcore.ssh.entity.AbstractBaseEntity;

/**
 * 人员绩效表
 * @author <a href="mailto:javaengine@outlook.com">Kaca Rich</a>
 *
 */
@Entity
@Table(name = "pm_user_performance")
@org.hibernate.annotations.Entity
public class UserPerformance extends AbstractBaseEntity<Long>  {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private User user;
	private Shop shop;//在没  人员 的情况下， 只填shop这个字段 ，生成一条记录 。。不能核发 .
	private Organization area; //在没有区域经理的情况下。。  ，生成一条记录 。。不能核发 
	private double amount; //应发金额
	private double realAmount; //实发 金额
	private List<AssignUser> assignUsers; //被分配在多个月份，多个店上 。。
//	private List<PAShopMonthDetail> paShopMonthDetails;//店铺下没人的情况下。。
	private String monthDate;//绩效月份,属于哪个月份 做的绩效。
	private PerformanceAssign performanceAssign;
	private PerformanceAssignStatus status;
	
	private User paymentUser;
	private Date paymentDate;
	
	@Column(name = "_amount")
	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_user_id") 
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "_real_amount")
	public double getRealAmount() {
		return realAmount;
	}

	public void setRealAmount(double realAmount) {
		this.realAmount = realAmount;
	}

	@OneToMany(targetEntity = AssignUser.class, cascade = {CascadeType.PERSIST })
	@JoinColumn(name="_user_performance_id")
	public List<AssignUser> getAssignUsers() {
		return assignUsers;
	}

	public void setAssignUsers(List<AssignUser> assignUsers) {
		this.assignUsers = assignUsers;
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_shop_id") 
	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	@Column(name = "_month_date")
	public String getMonthDate() {
		return monthDate;
	}

	public void setMonthDate(String monthDate) {
		this.monthDate = monthDate;
	}

//	@ManyToMany(fetch = FetchType.LAZY)
//	@JoinTable(name = "rs_pm_user_performance_pm_shop_month_detail_", joinColumns = @JoinColumn(name = "_user_performance_id"), inverseJoinColumns = @JoinColumn(name = "_shopmonth_detail_id"))
//	public List<PAShopMonthDetail> getPaShopMonthDetails() {
//		return paShopMonthDetails;
//	}
//
//	public void setPaShopMonthDetails(List<PAShopMonthDetail> paShopMonthDetails) {
//		this.paShopMonthDetails = paShopMonthDetails;
//	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_performance_assign_id") 
	public PerformanceAssign getPerformanceAssign() {
		return performanceAssign;
	}
	
	public void setPerformanceAssign(PerformanceAssign performanceAssign) {
		this.performanceAssign = performanceAssign;
	}

	@Column(name = "_status")
	@Enumerated(EnumType.ORDINAL)
	public PerformanceAssignStatus getStatus() {
		return status;
	}

	public void setStatus(PerformanceAssignStatus status) {
		this.status = status;
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_payment_user_id")
	public User getPaymentUser() {
		return paymentUser;
	}

	public void setPaymentUser(User paymentUser) {
		this.paymentUser = paymentUser;
	}

	@Column(name = "_payment_date")
	public Date getPaymentDate() {
		return paymentDate;
	}

	public void setPaymentDate(Date paymentDate) {
		this.paymentDate = paymentDate;
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_area_id") 
	public Organization getArea() {
		return area;
	}

	public void setArea(Organization area) {
		this.area = area;
	}
	
	
}
